package com.zpark.humpro.mapper;

import com.zpark.humpro.entity.Human;
import com.zpark.humpro.utils.JdbcUtil;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

/**
 * 与数据库连接，查询的数据保存到List表单中
 */
public class HumanInformationMapperImpl implements HumanInformationMapper {


    @Override
    public int addHuman(String name, int age, String adress) {
        Connection conn = JdbcUtil.getConnection();
        String sql = "insert into person_tb(name,age,adress) value(?,?,?)";
        try {
            PreparedStatement stat = conn.prepareStatement(sql);
            stat.setString(1,name);
            stat.setInt(2,age);
            stat.setString(3,adress);
            return stat.executeUpdate();

        } catch (SQLException e) {
            //一般会将异常记录到日志中
            return 0;
        }


    }
}
